import random
import math

c = [40,50,100,100,100,200,200,300,400,400]
f = [30,30,20,40,60,50,100,120,100,120]

s = 'graph'
for rep in range(0, 10):
    for num in range(0, 10):
        print num
        filename = s + "\\%d\\%d"%(num, rep) + ".txt"
        fl = open(filename, 'w')
        TOT = range(f[num]+c[num])
        GRAPH = []
        for i in TOT:
            GRAPH.append([])
            for j in TOT:
                if i == j:
                    GRAPH[i].append(0)
                elif i < j:
                    GRAPH[i].append(random.randint(0,10000))
                else:
                    GRAPH[i].append(GRAPH[j][i])

        for k in TOT:
            for i in TOT:
                for j in TOT:
                    if GRAPH[i][k]+GRAPH[k][j] < GRAPH[i][j]:
                        GRAPH[i][j] = GRAPH[i][k]+GRAPH[k][j]
        
        fl.write("%d %d\n"%(f[num],c[num]))
        
        for i in range(0, f[num] - 1):
            fl.write("%d "%random.randint(1,9999))
        fl.write("%d\n"%random.randint(1,9999))
        
        for i in range(0, f[num] - 1):
            fl.write("%d "%random.randint(1,int(math.sqrt(c[num]))))
        fl.write("%d\n"%random.randint(1,int(math.sqrt(c[num]))))

        for j in range(0, c[num] - 1):
            fl.write("%d "%random.randint(0,20000))
        fl.write("%d\n"%random.randint(0,20000))

        for i in range(0, f[num]):
            for j in range(0, c[num] - 1):
                fl.write("%d "%GRAPH[i][f[num]+j])
            fl.write("%d\n"%GRAPH[i][f[num]+c[num]-1])
        fl.close()
